import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JOptionPane;


public class SaveButton extends JButton implements ActionListener{

	private GuiClient gui;
	
	public SaveButton(GuiClient gui) {
		super();
		this.gui = gui;
		setText("save & exit");
		
		addActionListener(this);
	}

	@Override
	public void actionPerformed(ActionEvent e) {
		if(gui.saveAnswer()){
			gui.save(gui.getQ(), gui.getFileName());
			JOptionPane.showMessageDialog(this, "Answers have been saved");
			System.exit(0);
		}
		
	}
	
}
